export default Array.prototype.myReduce = function (cb, initialVal) {
    if (typeof cb !== 'function') {
        throw new Error(`arguments needs a callback function`)
    }
    let array = this
    let result = initialVal || (array.length ? array[0] : [])
    for (let i = initialVal ? 0 : 1; i < array.length; i++) {
        result = cb(result, array[i], i, array)
    }
    return result
}